




var popup_1 = new Popup('div_fly_1') ;

var popup_2 = new Popup('div_fly_2') ;
var popup_3 = new Popup('div_fly_3') ;

function hideElement(ele)
{
    
    document.getElementById(ele).style.visibility = 'hidden';
}

var current = 0;
var current_2 = 0;
var IsChild = false;
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }
  
  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

    function flyDiv(e,cat_id)
    {
        document.getElementById('div_fly_3').style.visibility = "hidden";
        popup_3.hide();
        
        var news_count = document.getElementById("news_count_"+cat_id).value;
        var cat_count = document.getElementById("cat_count_"+cat_id).value;
        if(cat_count == 0 && news_count == 0) 
        {
            current = 0;
            return;
        }
    
        var offsetfromcursorX = -4;
        var offsetfromcursorY = 0;
        var offsetdivfrompointerX = 0;
        var offsetdivfrompointerY = 0;
    
        var ie = document.all;
        var ns6 = document.getElementById && ! document.all;
    
        var curX = (ns6) ? e.pageX : e.offsetLeft;
        var curY = (ns6) ? e.pageY : e.offsetTop;
        
        curX = findPosX(e);
        curY = findPosY(e);
        
        var width = e.offsetParent.offsetWidth;

        var divFly = document.getElementById("divFly_"+cat_id);
        var div_fly_1 = document.getElementById('div_fly_1');
        
        div_fly_1.innerHTML = divFly.innerHTML;
        div_fly_1.style.left = curX + offsetfromcursorX - offsetdivfrompointerX + width + "px" ;
        div_fly_1.style.top = curY + offsetfromcursorY  + offsetdivfrompointerY  + "px";
        
        //if(!is_ie6)        
        //    div_fly_1.style.visibility = "visible";
        //else
        //{
            //popup_1.screen.style.top="0px";
		    //popup_1.screen.style.left="0px";
            popup_1 = new Popup('div_fly_1',{'constrainToScreen':false,'top':curY + offsetfromcursorY  + offsetdivfrompointerY ,'left':curX  + offsetfromcursorX - offsetdivfrompointerX + width});        
            //popup_1.options = {'constrainToScreen':false,'top':curY + offsetfromcursorY  + offsetdivfrompointerY ,'left':curX  + offsetfromcursorX - offsetdivfrompointerX + width};
            popup_1.show('top left');
        //}
        
        current = cat_id;
    }
    

    
    function move_out()
    {
        if(current == 0) return;        
        var div_fly_1 = document.getElementById('div_fly_1');
        //if(!is_ie6)
        //    div_fly_1.style.visibility = "hidden";
        //else
            popup_1.hide();
            if(popup_2.isShow)popup_2.hide();
    }
    
    function showDiv()
    {
        if(current == 0) return;
            popup_1.show('top left');
         popup_3.hide();
    }
    
    function hideDiv()
    {
        if(current == 0) return;
            popup_1.hide();
    }
    
    function flyDiv_2_hide(e,cat_id)
    {   
        popup_2.hide();

    }
    function flyDiv_2(e,cat_id)
    {   
        if(document.getElementById('news_count_2_'+cat_id).value == '0')
        {            
            popup_2.hide();popup_3.hide();
            return;
        }
        
        var offsetfromcursorX = -4;
        var offsetfromcursorY = 0;
        var offsetdivfrompointerX = 0;
        var offsetdivfrompointerY = 0;
    
        var ie = document.all;
        var ns6 = document.getElementById && ! document.all;
    
        var curX = (ns6) ? e.pageX : e.offsetLeft;
        var curY = (ns6) ? e.pageY : e.offsetTop;
        
        curX = findPosX(e);
        curY = findPosY(e);        
        var width = e.offsetParent.offsetWidth ;
        
        
        var divFly = document.getElementById("flyDiv_"+cat_id);
        divFly.style.left = curX + offsetfromcursorX - offsetdivfrompointerX + width + 200 + "px" ;        
        divFly.style.top = curY + offsetfromcursorY  + offsetdivfrompointerY  + "px";
        
        var divTemp ;
        
        if(IsChild == true)
        {
            divTemp = document.getElementById('div_fly_3');
            divTemp.style.left = curX + offsetfromcursorX - offsetdivfrompointerX + width  + "px" ;
            divTemp.style.top = curY + offsetfromcursorY  + offsetdivfrompointerY + 1  + "px";
            divTemp.innerHTML = divFly.innerHTML;
            popup_3.hide();
                        
            popup_3 = new Popup('div_fly_3',{'constrainToScreen':false,'top':curY + offsetfromcursorY  + offsetdivfrompointerY ,'left':curX  + offsetfromcursorX - offsetdivfrompointerX + width });        
            
            
            popup_3.show('top left');
        }
        else
        {
            divTemp = document.getElementById('div_fly_2');
            divTemp.style.left = curX + offsetfromcursorX - offsetdivfrompointerX + width  + "px" ;
            divTemp.style.top = curY + offsetfromcursorY  + offsetdivfrompointerY + 1  + "px";
            divTemp.innerHTML = divFly.innerHTML;
            
            popup_2.hide();
            popup_2 = new Popup('div_fly_2',{'constrainToScreen':false,'top':curY + offsetfromcursorY  + offsetdivfrompointerY ,'left':curX  + offsetfromcursorX - offsetdivfrompointerX + width + 204});        
            //popup_1.hide();
            
            popup_2.show('top left');
            popup_2.transition();
            //popup_1.show('top left');
            
        }
        current_2 = cat_id;
    }
    
   
    
    document.onmousemove = function()
    {
        var div_fly_1 = document.getElementById('div_fly_1');
        var div_fly_2 = document.getElementById('div_fly_2');
        if(IsChild == false)
        {   
            if(!popup_1.isShow && popup_2.isShow) 
            {         
                popup_2.hide();
            }
        }
    }
    
    function RedirectCat(cat_id)
    {
        window.location = 'TestMenu.aspx?Cat_ID='+cat_id;
    }
    

